<%@page import="cn.school.dao.impl1.StudentServiceImpl"%>
<%@page import="cn.school.service.Service"%>
<%@page import="cn.school.util1.PageSupport"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="cn.school.dao1.*,cn.school.service1.*,cn.school.entity.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="1" >
<tr>
<td>学号</td><td>姓名</td><td>电话</td><td>QQ号</td><td>微信</td><td>年级编号</td>
<td>来自哪里</td><td>出生日期</td><td>地址</td><td>密码</td>
</tr>
<%
//分页查询并显示
//当前页码
String currentPage=request.getParameter("pageIndex");
if(currentPage==null){
	currentPage="1";
}
int pageIndex=Integer.parseInt(currentPage);
//获取学生总数量
StudentService stu = new StudentServiceImpl();
int totalCount=stu.getTotalCount();
//每页显示几条学生信息，页面容量
int pageSize=8;
//获取总页数
PageSupport pageSupport=new PageSupport();
pageSupport.setCurrentPageNo(pageIndex);
pageSupport.setPageSize(pageSize);
pageSupport.setTotalCount(totalCount);
//总页数
int totalPage=pageSupport.getTotalPageCount();

//控制首页和尾页，防止无限加和无限减
if(pageIndex<1){
	pageIndex=1;
}else if(pageIndex>totalPage){
	pageIndex=totalPage;
}

/* Service service=new Service(); */
List<Student> list=stu.getPageStudentList(pageIndex,pageSize);
for(Student s:list){
%>	
<tr>
	<td><%=s.getStuno() %></td><td><%=s.getSname() %></td><td><%=s.getTelephone() %></td>
	<td><%=s.getQq() %></td><td><%=s.getWechat() %></td><td><%=s.getGradeid() %></td>
	<td><%=s.getFromcity() %></td>
	<td><%=s.getBirthday()
	
	
%></td><td><%=s.getAddress() %></td>
	<td><%=s.getPass() %></td>
</tr>
<%}%>
<ul>
<li>共<%=totalCount %>条记录    <%=pageIndex %>/<%=totalPage %>页</li>
<a href="studentInfo.jsp?pageIndex=1">首页</a>
<a href="studentInfo.jsp?pageIndex=<%=pageIndex-1%>">上一页</a>
<a href="studentInfo.jsp?pageIndex=<%=pageIndex+1%>">下一页</a>
<a href="studentInfo.jsp?pageIndex=<%=totalPage%>">最后一页</a>
</ul>
</table>
</body>
</html>